#include <iostream>
#include <algorithm>

using namespace std;
const int N = 2e5 + 5;
int x, num;
struct tr {
    int l, r, n;
} t[N * 18];
int head[N];
void build(int from, int l, int r) {
    t[x] = t[from];
    ++t[x].n;
    if (l == r) return ;
    int mid = l + r >> 1;
    if (num <= mid) t[x++].l = x, build(t[from].l, l, mid);
    else t[x++].r = x, build(t[from].r, mid + 1, r);
}
int check(int l, int r, int L, int R, int k) {
    if (L == R) return L;
    int lg = t[t[r].l].n - t[t[l].l].n, mid = L + R >> 1;
    if (lg < k) return check(t[l].r, t[r].r, mid + 1, R, k - lg);
    return check(t[l].l, t[r].l, L, mid, k);
}
int arr[N], brr[N];
signed main() {
    int n, m;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; ++ i) cin >> arr[i], brr[i] = arr[i];
    sort(brr + 1, brr + n + 1);
    int *end_ = unique(brr + 1, brr + 1 + n), endn = end_ - brr - 1;
    for (int i = 1; i <= n; ++ i) num = lower_bound(brr + 1, end_, arr[i]) - brr, head[i] = ++x, build(head[i - 1], 1, endn);
    while (m--) {
        int l, r, k;
        cin >> l >> r >> k;
        cout << brr[check(head[l - 1], head[r], 1, endn, k)] << '\n';
    }
    return 0;
}